package com.tjsinfo.tjsoa.workplan.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.workplan.vo.WorkPlanMain;

public class CheckDefalntWorkPlanMonthJiDuModleAction extends CheckDefalntWorkPlanMonthModleAction{
	private ISystemUserBo systemUserBo;
	
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.workplan.action.CheckDefalntWorkPlanMonthModleAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	 
		public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}

	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}

		@Override
		public ActionForward execute(ActionMapping mapping, ActionForm form,
				HttpServletRequest request, HttpServletResponse response)
				throws Exception {
			// TODO Auto-generated method stub
			try {
				Integer userid = Integer.parseInt(request.getParameter("id")); 
				Date date = new Date();
				Map<Integer, WorkPlanMain> map =	workPlanMainBo.selectWorkPlanTypeAndYearMAPNumberStart("Q", date.getYear() +1900, userid, 1);
				TSystemUser tjsuser = getDefinalutTjsuser(request);
				request.setAttribute("tjsuser", tjsuser);
				return forword(mapping, request, date, map);
			} catch (RuntimeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return mapping.findForward("error");
			}
		}
		protected TSystemUser getDefinalutTjsuser(HttpServletRequest request) {
			TSystemUser  tjsuser= systemUserBo.findByIdSystemUser(Integer.parseInt(request.getParameter("id")));
			//user.setUser_id(Integer.parseInt(request.getParameter("id")));
			return tjsuser;
		}
	
}
